package be.dch.objectprops.formatter;

import java.net.MalformedURLException;
import java.net.URL;

public class URLFormatter implements Formatter {

    @SuppressWarnings("rawtypes")
    
    public Class getFormatterClass() {
	return URL.class;
    }

    
    public Object parse(final String input) {
	try {
	    return new URL(input);
	} catch (final MalformedURLException e) {
	    return null;
	}
    }

    
    public String format(final Object input) {
	final URL url = (URL) input;
	return url.toExternalForm();
    }

    
    public void parse(final String input, Object result) {
	throw new UnsupportedOperationException("Method parse(String,Object) not supporeted.");
    }
}
